package com.ishare.common.constant;


import com.ishare.common.dto.exception.GlobalException;

/**
 * 全局返回码
 *
 * @author 李嘉宾
 */
public enum GlobalReturnCode {
    /**
     * 成功
     */
    SUCCESS(200, "成功"),
    /**
     * Token失效
     */
    TOKEN_FAILURE(403, "凭证失效，请重新登录"),
    /**
     * 参数异常
     */
    PARAM_ERROR(400, "参数异常"),
    /**
     * 系统异常
     */
    SYSTEM_ERROR(500, "系统异常，请联系管理员");

    private Integer code;

    /**
     * 返回消息
     */
    private String msg;

    GlobalReturnCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public GlobalException createException() {
        return new GlobalException(this.code, this.msg);
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}
